﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mapeo;
using BE;
using NHibernate;
using NHibernate.Criterion;

namespace DAL
{
    public class Menu_DAL: Controlador
    {
        public List<Menu> ObtenerMenus()
        {
            try
            {
                using (ISession Sesion = m_SessionFactory.OpenSession())
                {
                    ICriteria criteria = Sesion.CreateCriteria("Menu")
                        .AddOrder(Order.Asc("IDMenu"));
                    //criteria.SetMaxResults(100);
                    List<Menu> listado = (List<Menu>)criteria.List<Menu>();
                    return listado;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }

        public Menu ObtenerMenu(Int32 ID)
        {
            try
            {
                using (ISession Sesion = m_SessionFactory.OpenSession())
                {
                    Menu cp = (Menu)Sesion.CreateCriteria("Menu").Add(Restrictions.Eq("IDMenu", ID)).UniqueResult();
                    return cp;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }

    }
}
